package com.lxg.config;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;

/**
 * @author 陆小根
 * date: 2022/04/27
 * Description:
 */

public class ServletContainerInitConfig extends AbstractDispatcherServletInitializer {


  // 加载springmvc配置类
  @Override
  protected WebApplicationContext createServletApplicationContext() {
    // 初始化WebApplicationContext对象
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    // 加载指定配置类
    context.register(SpringMvcConfig.class);
    return context;
  }

  // 设置由SpringMVC控制器处理的请求映射路径
  @Override
  protected String[] getServletMappings() {
    return new String[]{"/"};
  }

  // 加载spring配置类
  @Override
  protected WebApplicationContext createRootApplicationContext() {
    return null;
  }
}
